package twitterdba;

import org.junit.Test;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;

import org.junit.*;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.*;
import java.io.*;
import java.io.ByteArrayOutputStream;
import org.hamcrest.Matcher;
import org.junit.Before;
import twitter4j.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.sql.*;
import java.util.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;

public class twitterDBAworkerTest 
{
	

    @Test
    public void dbRatingTest(){
    Connection c = null;
     Statement stmt = null;
     ResultSet rs = null;
	 PreparedStatement prepstmt = null;
	 twitterDBAworker tdba = new twitterDBAworker("Tweets.db", "TA/tweets3.zip", false, false);
    try{
    	
    
        
        Class.forName("org.sqlite.JDBC");
            c = DriverManager.getConnection("jdbc:sqlite:Tweets.db");
            stmt = c.createStatement();
           rs = stmt.executeQuery( "SELECT * FROM tweets;" );
           }
           catch ( Exception e ) {
			System.err.println( e.getClass().getName() + ": " + e.getMessage() );
			System.exit(0);
			return;
			}
           System.out.println(rs);
        double actual = tdba.dbRating();
        assertEquals(0.3333333333333333,actual, 0);
    }
    
    @Test
    public void retweetsToTweetsTest()
    {
    Connection c = null;
    Statement stmt = null;
    ResultSet rs = null;
    PreparedStatement prepstmt = null;
    twitterDBAworker tdba = new twitterDBAworker("Tweets.db", "TA/tweets3.zip", false, false);
    /*try{
    
        Class.forName("org.sqlite.JDBC");
            c = DriverManager.getConnection("jdbc:sqlite:Tweets.db");
            stmt = c.createStatement();
           rs = stmt.executeQuery( "SELECT * FROM tweets;" );
           }
           catch ( Exception e ) {
			System.err.println( e.getClass().getName() + ": " + e.getMessage() );
			System.exit(0);
			return;
			}*/
           System.out.println(rs);
        double actual = tdba.retweetsToTweets();
        assertEquals(100,actual, 0);
    
    }
    
    // @Test
    // public void wwhoRetweetedMostTest()
    // {
    // Connection c = null;
    // Statement stmt = null;
    // ResultSet rs = null;
    // PreparedStatement prepstmt = null;
    // twitterDBAworker tdba = new twitterDBAworker("Tweets.db", "TA/tweets3.zip", false, false);
    /*try{
    
        Class.forName("org.sqlite.JDBC");
            c = DriverManager.getConnection("jdbc:sqlite:Tweets.db");
            stmt = c.createStatement();
           rs = stmt.executeQuery( "SELECT * FROM tweets;" );
           }
           catch ( Exception e ) {
			System.err.println( e.getClass().getName() + ": " + e.getMessage() );
			System.exit(0);
			return;
			}*/
    //        System.out.println(rs);
    //     // String actual = tdba.retweetsToTweets();
    //     assertEquals(100,actual, 0);
    
    // }
}
